package logic

import (
	"context"
	"video/videorpc/videorpc"

	"video/api/internal/svc"
	"video/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CollectionListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCollectionListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CollectionListLogic {
	return &CollectionListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CollectionListLogic) CollectionList(req *types.CollectionListRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	data, err := l.svcCtx.VideoRpc.CollectionList(l.ctx, &videorpc.CollectionListRequest{
		UserId: req.UserId,
		Page:   req.Page,
		Size:   req.Size,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}
	return &types.Response{
		Message: "收藏列表展示成功",
		Data:    data,
		Code:    200,
	}, nil
}
